﻿namespace WMS6.Web.Configuration
{
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;

    public class CarrierQuery : BasePage
    {
        protected Button btnExport;
        protected Button btnList;
        protected Button btnNew;
        protected Button btnSearch;
        protected DropDownList ddlAddress;
        protected DropDownList ddlCarrirID;
        protected DropDownList ddlCarrirName;
        protected DropDownList ddlCity;
        protected DropDownList ddlIsActive;
        protected DropDownList ddlIsActiveOper;
        protected HtmlForm F2040;
        protected HtmlInputHidden hdnActionID;
        protected Label lblAddress;
        protected Label lblBu;
        protected Label lblCarrirID;
        protected Label lblCarrirName;
        protected Label lblCity;
        protected Label lblIsActive;
        protected HtmlLink mycss;
        protected ScriptManager ScriptManager1;
        protected TextBox txtAddress;
        protected TextBox txtCarrirID;
        protected TextBox txtCarrirName;
        protected TextBox txtCity;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("CarrierList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("CarrierList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void InitDropDownLists()
        {
            base.InitQueryDDL(this.ddlCarrirID, 0);
            base.InitQueryDDL(this.ddlCarrirName, 0);
            base.InitQueryDDL(this.ddlCity, 0);
            base.InitQueryDDL(this.ddlAddress, 0);
            base.InitQueryDDL(this.ddlIsActiveOper, 0);
            base.InitIsActiveDDL(this.ddlIsActive, 0);
        }

        private void LoadData()
        {
            if (!string.IsNullOrEmpty(base.Request.QueryString["action"]))
            {
                this.btnNew.Visible = false;
                this.btnExport.Visible = false;
                this.ddlIsActive.SelectedValue = "Y";
                this.ddlIsActive.Enabled = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.InitDropDownLists();
                this.LoadData();
            }
        }

        public string Address
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtAddress.Text.Trim()))
                {
                    return base.GetParamsString(this.txtAddress.Text.Trim(), this.ddlAddress.SelectedValue);
                }
                return "";
            }
        }

        public string CarrierID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCarrirID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCarrirID.Text.Trim(), this.ddlCarrirID.SelectedValue);
                }
                return "";
            }
        }

        public string CarrierName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCarrirName.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCarrirName.Text.Trim(), this.ddlCarrirName.SelectedValue);
                }
                return "";
            }
        }

        public string City
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtCity.Text.Trim()))
                {
                    return base.GetParamsString(this.txtCity.Text.Trim(), this.ddlCity.SelectedValue);
                }
                return "";
            }
        }

        public string IsActive
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsActive.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsActive.SelectedValue, this.ddlIsActiveOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

